<h3>Define an interface</h3>

<pre>type Car interface {
   Drive() string
}</pre>

<h3>Implement an interface</h3>

There is no implements or inherits or similar keyword. The relationship of types to another interface is implicit.

So to implement the interface define above we declare a struct with the same method along with an implementation.

<pre>type Porsche struct {
}

func (p Porsche) Drive() string {
   return "100mph";
}
</pre>

See also: <?add topic='Go Struct'?>

<h3>Empty Interface</h3>

Using the type

<pre>interface{}</pre>

you can specify an empty interface that is implemented by all types. So if you want to build a function taking a type-less parameter use the empty interface

<pre>func debug(x interface{}) {
   // do something
}</pre>
